package _021_11_19

func _back(n int, alphaM map[uint8]string, digits string, path []uint8, ret *[]string) {
	if n == len(digits) {
		temp := ""
		for i := 0; i < len(path); i++ {
			temp += string(path)
		}
		*ret = append(*ret, temp)
		return
	}

	for i := 0; i < len(alphaM[digits[n]]); i++ {
		path = append(path, alphaM[digits[n]][i])
		_back(n+1, alphaM, digits, path, ret)
		path = path[:len(path)-1]
	}
}

func letterCombinations(digits string) []string {

	alphaM := make(map[uint8]string)
	alphaM[2] = "abc"
	alphaM[3] = "edf"
	alphaM[4] = "ghi"
	alphaM[5] = "jkl"
	alphaM[6] = "mno"
	alphaM[7] = "pqrs"
	alphaM[8] = "tuv"
	alphaM[9] = "wxyz"

	ret := make([]string, 0)
	_back(0, alphaM, digits, []uint8{}, &ret)
	return ret
}
